// class UseEvent {
//   constructor() {
//     this.eventMap = {}
//   }
// }


// const useEvent = new UseEvent()
// useEvent.dispatch('field', (form, val) => {
//   console.log(val)
// })

// useEvent.listen('field', (form, val) => {
//   console.log(val)
// })
export type Form = Record<string, any>
export interface Watcher {
  update: (form: Form) => void
}

class Dep {
  subscribers: Watcher[] = []
  form: Form = {}
  add(watcher: Watcher) {
    this.subscribers.push(watcher)
  }
  notify() {
    this.subscribers.forEach(watcher => watcher.update(this.form))
  }
}
const dep = new Dep()
export default dep
